import { createSlice } from '@reduxjs/toolkit'

export const userslice = createSlice({
  name: 'userslice',
  initialState: {
   perlist:[]
  },
  reducers: {
    addper(state,{payload}){
       state.perlist.map((item,index)=>{
        let c=0
        if(item.id==payload.id){
            c++
        }
        if(c==0){
            state.perlist.push(payload)
        }
       })
    }
  }
})
// 每个 case reducer 函数会生成对应的 Action creators
export const {addper} = userslice.actions

export default userslice.reducer